Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements the TooManyMethods rule, a PHPStan extension that detects classes, interfaces, traits, and enums with an excessive number of methods, helping identify code that violates the Single Responsibility Principle.
Key changes:
- Adds a new TooManyMethods rule with configurable method count threshold and pattern-based method filtering
- Provides comprehensive test coverage across multiple configuration scenarios
- Includes complete documentation and README integration
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Rules/TooManyMethods/TooManyMethodsRule.php | Main rule implementation analyzing ClassLike nodes and counting methods with optional pattern-based filtering |
| src/Rules/TooManyMethods/Config.php | Configuration class with max_methods threshold and ignore_pattern regex support |
| config/extension.neon | Schema definition, default parameters, and service registration for the rule |
| tests/Rules/TooManyMethods/TooManyMethodsRuleTest.php | Default configuration tests validating error reporting for classes, traits, interfaces, and enums |
| tests/Rules/TooManyMethods/NoIgnorePatternTest.php | Tests verifying all methods are counted when ignore_pattern is empty |
| tests/Rules/TooManyMethods/CustomMaxMethodsTest.php | Tests validating custom max_methods threshold behavior |
| tests/Rules/TooManyMethods/Fixture/ExampleClass.php | Test fixtures with various method counts and naming patterns |
| tests/Rules/TooManyMethods/config/*.neon | Test configuration files for different rule scenarios |
| docs/TooManyMethods.md | Complete rule documentation with configuration options and examples |
| README.md | Added TooManyMethods to the Design rules table |
| CLAUDE.md | AI coding instructions for the project (appears to be project documentation) |
| .gitignore | Added .claude/settings.local.json to ignore list |
Validates the ignore_pattern configuration by checking both preg_match return value and preg_last_error() to catch all potential regex errors, throwing InvalidArgumentException with a descriptive message when invalid.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #44